{* $Id$ *}
{include_core file="admin/lib/header.html" title="积分记录添加"}
<div class="page-header border-bottom clearfix">
  <h2 class="left">积分记录管理<span>为用户增加积分</span></h2>
  <a href="{AnUrl('user/admin/index')}" class="btn btn-default btn-sm right">&lt;&nbsp;返回用户列表</a>
  <a href="{AnUrl('score_record/admin/index')}" class="btn btn-default btn-sm right">&lt;&nbsp;返回积分记录列表</a>
</div>
<!--start:积分记录新增-->
<div class="add-form">
  <form action="{AnUrl('score_record/admin/create')}" method="post" enctype="multipart/form-data">
    <input type="hidden" name="score[user_id]" value="{$user_info.id}" />
    <table class="table" cellpadding="0" cellspacing="0" style="position:relative;">
      <tr>
        <th><label class="add-f-label" for="">积分类型：</label></th>
        <td>
          <select name="score[res_id]" id="">
            {foreach $score_type_list as $k=>$v}
              <option value="{$v.id}">{$v.res_name}</option>
              {if $v.type_list}
                {foreach $v.type_list as $key=>$val}
                <option value="{$val.id}">&nbsp;&nbsp;|--&nbsp;&nbsp;{$val.res_name}</option>
                {/foreach}
              {/if}
            {/foreach}
          </select>
          <span class="btn btn-default btn-sm">
            <a href="{AnUrl('score_type/admin/add')}">&nbsp;&nbsp;没找到类型? 点击添加</a>
          </span>
        </td>
      </tr>
      <tr style="position:relative;">
        <th><label for="" class="add-f-label">用户名：</label></th>
        <td>
          <input type="hidden" name="id" value="{$user_info.id}" />
          {$user_info.user_name}
        </td>
      </tr>
      <tr>
        <th valign="top"><label class="add-f-label" for="">积分：</label></th>
        <td>
          <input name="score[score]" style="width:490px;" type="text" class="add-f-ipt1" maxlength="50" placeholder="输入积分,只能是整数" >
          <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>输入要添加的积分数</div>
        </td>
      </tr>
      
      <tr><th>&nbsp;</th><td class="noborder"><button type="submit" class="btn btn-success">&nbsp;&nbsp;&nbsp;添加&nbsp;&nbsp;&nbsp;</button></td></tr>
    </table>
  </form>
</div>
<!--end:积分记录新增-->
<script>

$(function(){ 
  //控制ajax的同步还是异步
  var ajaxAsync = true;   
  var checkUserUnique = false;

  // 提交验证
  $('form').submit(function(){
    //验证
    if( $('input[name="score[score]"]').val() == ''){
      showMsg('积分数不能为空!');
      return false;
    };
  });

  //积分除了数字之外的字符过滤
  {literal}
  $('input[name="score[score]"]').keyup(function(){
    var reg = /[^-+0123456789]+/g;
    $(this).val($(this).val().replace(reg, ''));
    
    //获取第一个字符
    $firstLetter = $(this).val().substr(0, 1);
    var signReg = /\D+/g;
    //获取剩余字符过滤
    $leftLetter = $(this).val().substr(1);
    $leftLetter = $leftLetter.replace(signReg, '');
    //最后拼接
    $(this).val($firstLetter+$leftLetter);
    
  });
  {/literal}
  
});

</script>
{include_core file="admin/lib/footer.html"}